#!/bin/sh

sync
mount_point="/run/mnt-persist"
retries=3

echo "Attempting to remount $mount_point as read-only with a number of $retries retries"

while [ "$retries" -gt 0 ]; do
    if mount -o ro,remount "$mount_point"; then
        exit 0
    fi
    retries=$((retries - 1))
    sleep 1
done

exit 1
